<template>
<view class="work-container">
		<!-- 搜索框-->
		<uni-search-bar @confirm="handleQuery"  v-model="queryParams.pigCode" placeholder="请输入耳号"
			bgColor="#ffffff" >
		</uni-search-bar>
		<uni-group mode="card" v-for="(item, index) in pigTransferList" :index="index" :key="index">
			<view class="code">
				<text style="font-size:18px">母猪耳号：{{item.pigCode}}</text>
				<uni-icons class="icon" type="right" size="15" color="#000000"
						   @click="toTransferDetials(item.transferId)"></uni-icons>
			</view>
			<hr/>
			<view class="message">
				<view  v-if="item.transferOutPhouseType ==1"> 转出栏舍类型：{{$dict.selectDictLabel('hmy_park_type', 1)}} </view>
				<view  v-else-if="item.transferOutPhouseType ==2"> 转出栏舍类型：{{$dict.selectDictLabel('hmy_park_type', 2)}} </view>
				<view  v-else-if="item.transferOutPhouseType ==3"> 转出栏舍类型：{{$dict.selectDictLabel('hmy_park_type', 3)}} </view>
				<view> 转出栏舍编码：{{item.transferOutPhouseCode}}</view>
				<view  v-if="item.transferIntoPhouseType ==1"> 转入栏舍类型：{{$dict.selectDictLabel('hmy_park_type', 1)}} </view>
				<view  v-else-if="item.transferIntoPhouseType ==2"> 转入栏舍类型：{{$dict.selectDictLabel('hmy_park_type', 2)}} </view>
				<view  v-else-if="item.transferIntoPhouseType ==3"> 转入栏舍类型：{{$dict.selectDictLabel('hmy_park_type', 2)}} </view>
				<view> 转入栏舍编码：{{item.transferIntoPhouseCode}}</view>
				<view> 转舍日期：{{item.transferDate}}</view>
			</view>
		</uni-group>
	<!-- 加载更多 -->
	<uni-load-more iconType="auto" :status="status" />
		<uni-fab :pattern="pattern" :horizontal="horizontal" :vertical="vertical"
				@fabClick="fabClick" />
	</view>
</template>

<script>

import { listPigTransfer,getPigTransfer, addPigTransfer, updatePigTransfer, delPigTransfer} from "@/api/hmy/pigTransfer";
export default {
  name: "PigTransfer",
  dicts: ['hmy_pig_type','hmy_park_type'],
  data() {
    return {
		// 进货表格数据
		pigTransferList: [],
		//增加的加号
		horizontal: 'right',
		vertical: 'bottom',
		pattern: {
			buttonColor: '#55aa7f',
		},
		//加载更多
		status: 'more',
		total: '',

		// 查询参数
		queryParams: {
			pageNum: 1,
			pageSize: 10,
			type: undefined,

		}
	};
  },
	created() {
		this.getList();
	},
	//上拉加载
	onReachBottom() {
		this.queryParams.pageSize += 5;
		this.getList();
		if (this.pigTransferList.length >= this.total) {
			this.status = 'noMore';
			//console.log(this.status);
		} else {
			this.status = 'loading';
		}
	},
	methods: {

		/** 查询猪只出场记录列表 */
		getList() {
			//显示加载框
			uni.showLoading({title: '加载中'});
			listPigTransfer(this.queryParams).then(response => {
				this.pigTransferList = response.rows;
				this.total = response.total;
				//隐藏加载框
				uni.hideLoading();
			});
		},

		//新增猪只出场记录加号
		fabClick() {
			this.$tab.navigateTo('/pages/hmy/pigTransfer/pigTransferAdd');
		},



		/** 搜索按钮操作 */
		handleQuery() {
			this.queryParams.pageNum = 1;
			this.getList();
		},

		//详情
		toTransferDetials(e) {
			console.log("xiangqing", e)
			this.$tab.navigateTo('/pages/hmy/pigTransfer/pigTransferDetials?id=' + e);
		}

	}
};


</script>
<style lang="scss">

	/* #ifndef APP-NVUE */
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		min-height: 100%;
		height: auto;
		background-color: #fcfcfc;
	}

	view {
		font-size: 16px;
		line-height: inherit;
	}
	/* #endif */
	.code{
		margin-bottom :5px;
	}
	.icon{
		float:right;
		margin-right:10px;
		margin-top :5px;
	}
	.message{
		margin-top:5px;
		color: #989897;
		line-height: 25px;
	}
</style>
